package component;

import javax.swing.*;

/**
 * @author zhongwen
 * @description 垂直分割主界面
 * @date 2021-12-10 8:24
 */
public class VerticalSplitPane extends JSplitPane {

    private JPanel topPanel;
    private JPanel downPanel;
    public VerticalSplitPane(JPanel topPanel, JPanel downPanel){
        this.topPanel = topPanel;
        this.downPanel = downPanel;
        init();
    }

    private void init(){
        this.setOrientation(VERTICAL_SPLIT);
        this.setContinuousLayout(true);
        this.setLeftComponent(topPanel);
        this.setRightComponent(null);
        this.setDividerSize(0);
    }

    public void removeOrAddDownPanel(){
        if(this.getRightComponent() != null){
            this.remove(downPanel);
            this.setDividerSize(0);
        }
        else{
            this.setRightComponent(downPanel);
            this.setDividerLocation(0.75);
            this.setDividerSize(3);
        }
    }

    public void showDownPanel(){
        if(this.getRightComponent() != null){
        }
        else{
            this.setRightComponent(downPanel);
            this.setDividerLocation(0.7);
            this.setDividerSize(3);
        }
    }

    public JPanel getDownPanel(){
        return downPanel;
    }
}
